home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 October / macformat-005.iso / Shareware City / Developers / MungeImage Source / ftn-e0-0005 < prev    next >
Encoding:
Text File  |  1994-06-18  |  9.2 KB  |  229 lines  |  [TEXT/MPS ]

  1. Apple II
  2. File Type Notes
  3. _____________________________________________________________________________
  4.                                                   Developer Technical Support
  5.  
  6. File Type:       $E0 (224)
  7. Auxiliary Type:  $0005
  8.  
  9. Full Name:       DiskCopy disk image
  10. Short Name:      DiskCopy disk image
  11.  
  12. Written by:      Matt Deatherage, Dave Lyons & Steve Christensen     May 1992
  13.  
  14. Files of this type and auxiliary type contain disk images from Apple's
  15. DiskCopy program on the Macintosh.
  16. _____________________________________________________________________________
  17.  
  18. DiskCopy is a program written by Steve Christensen of Apple Computer, Inc.,
  19. for internal use in duplicating and distributing 3.5" floppy disks.  Because
  20. of its utility in distributing disk images on the Macintosh, DiskCopy is used
  21. in several Apple developer products even though DiskCopy is not an official
  22. Apple product and is not supported as such.
  23.  
  24. Since the monthly Developer CD Series discs contain many DiskCopy disk images,
  25. and since the AppleShare and HFS FSTs in System Software 6.0 and later
  26. automatically translate DiskCopy files (HFS file type dImg and creator dCpy)
  27. to Apple II file type $E0 and auxiliary type $0005, the format is provided
  28. here for your utility use only.  Apple does not guarantee that files not
  29. generated by DiskCopy will work with DiskCopy.
  30.  
  31.  
  32. DEFINITIONS
  33.  
  34. DiskCopy uses a simple checksum algorithm to help insure data integrity for
  35. archived disk images. The algorithm for generating the 32-bit checksum is as
  36. follows:
  37.  
  38.      Initialize checksum to zero
  39.      For each data REVERSE WORD:
  40.           Add the data REVERSE WORD to the checksum
  41.           Rotate the 32-bit checksum right one bit (wrapping bit 0 to bit 31)
  42.  
  43. The following 65816 assembly language routine calculates a DiskCopy checksum.
  44. It's not a speedy operation--it takes about 12 seconds to calculate the
  45. checksum on an 800K disk image.  Anyone finding an assembly routine that can
  46. perform this task in under 5 seconds may apply for their IIgs Certificate of
  47. Deityship, as documented in the File Type Note for file type $B6.
  48.  
  49. (Oh, by the way, any entries have to be under 1K in size--the following
  50. routine is 88 bytes.  So don't think unwinding loops is your ticket to fame
  51. and fortune.)
  52.  
  53. ****************************************************************************
  54. *
  55. * Compute checksum for DiskCopy data
  56. *
  57. * v1.2  by David A. Lyons, 18-May-92
  58. *
  59. * MPW IIgs assembly format
  60. *
  61. * Inputs on stack:
  62. *    Push pointer to data (long)
  63. *    Push size of data (long)  (Must be even!)
  64. *    JSL CalcChecksum
  65. *    STA TheChecksum+2
  66. *    STX TheChecksum
  67. *
  68. * Output:
  69. *    Checksum in A and X (bytes +0 and +1 in X, bytes +2 and +3 in A)
  70. *    (The inputs have been removed from the stack)
  71. *
  72. ****************************************************************************
  73. CalcChecksum        PROC
  74.                     phd                 ;save caller's direct page reg
  75.                     lda #0
  76.                     pha
  77.                     pha                 ;push initial checksum value (zero)
  78.                     tsc
  79.                     tcd
  80.  
  81. checksum            equ 1
  82. oldD                equ checksum+4
  83. theRTL              equ oldD+2
  84. dataSize            equ theRTL+3
  85. dataPtr             equ dataSize+4
  86.  
  87. *** Set dataSize to -(dataSize/2)-1 so we can count up by one
  88. *** (instead of down by two) to see when we're done
  89.                     lda <dataSize+2
  90.                     lsr a
  91.                     eor #$ffff
  92.                     sta <dataSize+2
  93.                     lda <dataSize
  94.                     ror a
  95.                     eor #$ffff
  96.                     sta <dataSize
  97.  
  98.                     ldy #0
  99. nextWord            inc <dataSize
  100.                     bne moreData
  101.                     inc <dataSize+2
  102.                     beq noMoreData
  103. moreData
  104.  
  105. *** Get next 16-bit word from the data buffer
  106.                     lda [<dataPtr],y
  107.                     xba                 ;swap to 65816 byte order
  108.  
  109. *** Add the data word to the checksum
  110.                     clc
  111.                     adc <checksum
  112.                     sta <checksum
  113.                     bcc noCksumRoll
  114.                     inc <checksum+2
  115. noCksumRoll
  116. *** Rotate the 32-bit checksum right one bit, wrapping bit 0 into bit 31
  117.                     lda <checksum+2
  118.                     lsr a
  119.                     ror <checksum
  120.                     bcc bit0was0
  121.                     ora #$8000          ;if we rotated a 1 out of bit 0,
  122. bit0was0            sta <checksum+2     ;  then set bit 31
  123.  
  124. *** Advance to the next word and go back for more
  125.                     iny
  126.                     iny
  127.                     bne nextWord        ;go back for more data
  128.                     inc <dataPtr+2
  129.                     bra nextWord        ;go back for next bank of data
  130.  
  131. noMoreData          pla
  132.                     xba
  133.                     tay
  134.                     pla
  135.                     xba
  136.                     tax                 ;pull checksum into YX (put in 68000
  137. order)
  138.  
  139.                     pld                 ;restore caller's direct page reg
  140.  
  141.                     lda 2,s
  142.                     sta 2+8,s
  143.                     lda 1,s
  144.                     sta 1+8,s
  145.                     pla
  146.                     pla
  147.                     pla
  148.                     pla                 ;discard input values
  149.  
  150.                     tya
  151.                     rtl
  152.  
  153.                     EndP
  154.  
  155.                     END
  156.  
  157. The following definition is used in this document in addition to those defined
  158. for all Apple II file types:
  159.  
  160. Checksum   A 32-byte quantity calculated using the previously-defined
  161.            algorithm.  When these are contained in the file, they are in
  162.            REVERSE order.
  163.  
  164.  
  165. FILE STRUCTURE
  166.  
  167. All of the information for a DiskCopy disk image is in the data fork.  The
  168. resource fork usually contains Macintosh resources (in Macintosh resource fork
  169. format), including vers resources listing the checksums.  This allows
  170. Macintosh users to use the Macintosh Finder's "Get Info..." function to
  171. quickly examine the checksums.
  172. The File Format
  173.  
  174. Because this is a native Macintosh file format, all the multi-byte constants
  175. are stored in Reverse order.
  176.  
  177. diskName       (+000)  64 Bytes  A Pascal String containing the name of the
  178.                                  disk.  This field takes 64 bytes
  179.                                  regardless of the length of the String.
  180. dataSize       (+064) Rev. Long  The number of bytes (not blocks) of user
  181.                                  data.  User data is the 512 bytes of each
  182.                                  block that a normal block-reading command
  183.                                  returns.
  184. tagSize        (+068) Rev. Long  The number of bytes of tag data.  Tag data
  185.                                  is the extra 12 bytes of "scavenger"
  186.                                  information present on 400K and 800K
  187.                                  Macintosh disks.  Apple II operating
  188.                                  systems always leave these bytes zeroed,
  189.                                  and they're not present on 720K or 1440K
  190.                                  disks.  If there are no tag bytes, this
  191.                                  field will be zero.
  192. dataChecksum   (+072)  Checksum  Checksum of all the user data on the disk.
  193.                                  The checksum algorithm is called for the
  194.                                  entire disk, not on a block-by-block or
  195.                                  sector-by-sector basis.  This is in
  196.                                  Reverse order (most significant byte
  197.                                  first).
  198. tagChecksum    (+076)  Checksum  Checksum of all the tag data on the disk.
  199.                                  If there is no tag data, this should be
  200.                                  zero.  This is in Reverse order (most
  201.                                  significant byte first).
  202. diskFormat     (+080)      Byte  0 = 400K
  203.                                  1 = 800K
  204.                                  2 = 720K
  205.                                  3 = 1440K  (all other values are reserved)
  206. formatByte     (+081)      Byte  $12 = 400K
  207.                                  $22 = >400K Macintosh (DiskCopy uses this
  208.                                        value for all Apple II disks not
  209.                                        800K in size, and even for some of
  210.                                        those)
  211.                                  $24 = 800K Apple II disk
  212. private        (+082) Rev. Word  Must be $0100.  If this field is not
  213.                                  $0100, the file may be in a different
  214.                                  format.
  215. userData       (+084)            dataSize Bytes
  216.                                  The data blocks for the disk.  These are
  217.                                  in order from block zero through the end
  218.                                  of the disk.
  219. tagData    (+xxx) tagSize Bytes  The tag data for this disk, starting with
  220.                                  the tag data for the first block and
  221.                                  proceeding in order.  This field is not
  222.                                  present for 720K and 1440K disks, but it
  223.                                  is present for all other formats even if
  224.                                  all the data is zeroes.
  225. Further Reference
  226. _____________________________________________________________________________
  227.  
  228.    o   GS/OS Reference
  229.